package reflective;

import extend.Employee;

import java.lang.reflect.InvocationTargetException;
import java.net.URL;

public class ReflectiveTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Employee e = new Employee("Carl Johnson", 8888, 24);
        // Object类中的getClass()方法会返回一个Class类型的实例。
        Class<? extends Employee> cl = e.getClass();

        // Class实例的常用方法：
        System.out.println(e.getClass().getName() + " " + e.getName());

        // 使用静态方法获得类名对应的class对象
        String className = "java.util.Random";
        Class c = Class.forName(className);
        Object obj = c.getConstructor().newInstance();
    }
}
